# coding=utf-8
import json


class ReadJson:

    def __init__(self):
        json_str = "../common/config.json"
        with open(json_str, 'r', encoding='utf-8') as f:
            self.data = json.load(f)

    def get_env(self, env, fieldname):
        print(self.data[env][fieldname])
        return self.data[env][fieldname]

    def get_url(self, project, fieldname):
        print(self.data["url"][project][fieldname])
        return self.data["url"][project][fieldname]

    def get_header(self, fieldname):
        print(self.data["headers"][fieldname])
        return self.data["headers"][fieldname]

    def get_body(self, project, fieldname):
        print(self.data["body"][project][fieldname])
        return self.data["body"][project][fieldname]


if __name__ == '__main__':
    a = ReadJson()
    url = (a.get_url ("jgj_syb", "jgj_host")) % (a.get_env ("test", "suffix")) + a.get_url ("jgj_syb", "jgj_login_url")
    print (url)
    # a.get_header ("header_json")
    # a.get_body("jgj_syb", "jgj_body_smg")
